using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMDoLineController
    {
        private clsConnect cls = new clsConnect();

        #region Getdata
        public DataTable BindGirdTMDoLine(string keywords)
        {
            return cls.Search("sp_TMDoLine_Search", "@KeyWords", keywords);
        }
        public DataTable BindGirdTMDoLineDetail(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDoLine_Detail_Edit", "@RowID", id);
        }
        public DataTable BindGridTMDoLineDetailTranf(int id)
        {
            return cls.LayDuLieuParameter("sp_TMCommandTransferOrderLine_Detail", "@TMCommandTransferOrder_Id", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMDoLine(clsTMDoLineProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@No_", data.No_);
            cls.AddParameter("@ItemNo", data.ItemNo);
            cls.AddParameter("@Unit", data.Unit);
            cls.AddParameter("@NetWeight", data.NetWeight);
            cls.AddParameter("@Amount", data.Amount);
            cls.AddParameter("@Total", data.Total);
            cls.AddParameter("@PalletNo", data.PalletNo);
            cls.AddParameter("@TypeCell", data.TypeCell);
            cls.AddParameter("@CellNewStatus", data.CellNewStatus);
            cls.AddParameter("@CellNo", data.CellNo);
            cls.AddParameter("@Description", data.Description);
            cls.AddParameter("@DocumentDate", data.DocumentDate);
            cls.AddParameter("@PostingDate", data.PostingDate);
            cls.AddParameter("@ExpiryDate", data.ExpiryDate);
            cls.AddParameter("@UserID", data.UserID);
            cls.AddParameter("@Status", data.Status);
            cls.ExecuteNonQuery("sp_TMDoLine_Insert");
            return true;
        }
        public bool UpdateTMDoLine(clsTMDoLineProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@RowID", data.RowID);
            cls.AddParameter("@No_", data.No_);
            cls.AddParameter("@ItemNo", data.ItemNo);
            cls.AddParameter("@Unit", data.Unit);
            cls.AddParameter("@NetWeight", data.NetWeight);
            cls.AddParameter("@Amount", data.Amount);
            cls.AddParameter("@Total", data.Total);
            cls.AddParameter("@PalletNo", data.PalletNo);
            cls.AddParameter("@TypeCell", data.TypeCell);
            cls.AddParameter("@CellNewStatus", data.CellNewStatus);
            cls.AddParameter("@CellNo", data.CellNo);
            cls.AddParameter("@Description", data.Description);
            cls.AddParameter("@DocumentDate", data.DocumentDate);
            cls.AddParameter("@PostingDate", data.PostingDate);
            cls.AddParameter("@ExpiryDate", data.ExpiryDate);
            cls.AddParameter("@UserID", data.UserID);
            cls.AddParameter("@Status", data.Status);
            cls.ExecuteNonQuery("sp_TMDoLine_Update");
            return true;
        }
        public bool DeleteTMDoLine(int id)
        {
            cls.Delete("sp_TMDoLine_Delete", "@RowID", id);
            return true;
        }
        public bool UpdateTMDoLineQuality(clsTMDoLineProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Amount", data.Amount);
            cls.AddParameter("@RowID", data.RowID);
            cls.ExecuteNonQuery("sp_TMDoLine_Update_Quality");
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMDoLine_Search", "KeyWords", keywords);
        }
        #endregion
    }
}